package com.jp.proxy.httpprocessor;

import android.content.Context;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import java.util.Map;

/**
 * @ProjectName : HttpProcessor_20200413
 * @Author : Jason
 * @Time : 2021/8/29 14:06
 * @Description : 文件描述
 */
public class VolleyProcessor implements IHttpProcessor {

    private static RequestQueue mQueue = null;

    public VolleyProcessor(Context context) {
        //Volley需要上下文创建队列
        mQueue = Volley.newRequestQueue(context);
    }

    @Override
    public void postRequest(String url, Map<String, Object> params, final IRequestCallBack callback) {
        StringRequest stringRequest = new StringRequest(Request.Method.POST,
                url,
                response -> callback.onSuccess(response), error -> {
            callback.onFailure(error.networkResponse.toString());
        });
        mQueue.add(stringRequest);
    }

    @Override
    public void get(String url, Map<String, Object> params, IRequestCallBack callback) {

    }

}
